package weixintest;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/4/13 22:00
 */
public class ChildClass extends ParentClass {
    protected final String name = "ChildClass";
    public int a = 5;

    public static void monday() {
        System.out.println("子类的monday方法");
    }

    public static void main(String[] args) {
        ChildClass childClass = new ChildClass();
        //向上转型
        ParentClass parentClass = childClass;

        System.out.println("---------隐藏变量测试----------------");
        childClass.a = 10;
        System.out.println("parent:a=" + parentClass.a);
        System.out.println("child:a=" + childClass.a);

        System.out.println("---------静态方法隐藏测试------------");
        ParentClass.monday();
        ChildClass.monday();

        System.out.println("---------方法的重写测试-------------");
        parentClass.count();
        childClass.count();

        System.out.println("---------内部类的隐藏测试-------------");
        ParentClass.InnerClass pa = parentClass.new InnerClass();
        ChildClass.InnerClass ch = childClass.new InnerClass();
    }

    @Override
    public void count() {
        System.out.println("子类的count方法");
    }

    class InnerClass {
        public InnerClass() {
            System.out.println("子类的内部类");
        }
    }

}
